<template>
	<view>
		<view class="top">
			<image class="top_img" mode="aspectFill" :src="baseURL + img"></image>
			<view class="name">{{name}}</view>
		</view>
		<view class="box">
			<view class="lists-two">
				<view class="item" v-for="(item,index) in wallpaperUrl" :key="index" @click="download(item.id)">
					<image :src="baseURL + item.img" mode="aspectFill"></image>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		ByCategoryList
	} from '../../utils/api/index.js';
	import {
		baseURL
	} from "../../utils/httpRequest/baseURL.js"
	export default {
		data() {
			return {
				name: '',
				img: '',
				baseURL,
				wallpaperUrl: ''
			};
		},
		onLoad(options) {
			let img = options.img
			let name = options.name
			this.img = img
			this.name = name
			let categoryId = options.categoryId
			this.Wallpaper(categoryId)
		},

		methods: {
			async Wallpaper(categoryId) {
				const res = await ByCategoryList(categoryId)
				console.log(res);
				this.wallpaperUrl = res.data
			},

			download(id) {
				uni.navigateTo({
					url: `/pages/download/download?id=${id}` // 正确的路由格式，传递id作为参数
				});
			}

		}
	};
</script>

<style scoped lang="scss">
	.top {
		width: 100%;
		height: 350rpx;
		position: relative;
		margin-bottom: -30rpx;
		z-index: -1;
		background-color: rgba(0, 0, 0, 0.42);

		.top_img {
			width: 100%;
			height: 350rpx;
		}

		.name {
			position: absolute;
			bottom: 100rpx;
			left: 50rpx;
			font-weight: bold;
			font-size: 36rpx;
			color: #fff;
		}
	}

	.content {
		padding: 40rpx 0;
	}

	.box {
		background-color: #fff;
		z-index: 99999;
		border-radius: 20rpx;
		margin-top: -50rpx;
		padding: 0 25rpx;
	}

	.lists-two {
		display: flex;
		justify-content: space-between;
		align-items: center;
		flex-wrap: wrap;
		padding-top: 25rpx;
	}

	.lists-two .item {
		position: relative;
		width: 48.5%;
		height: 500rpx;
		margin-bottom: 30rpx;
		overflow: hidden;
	}

	.lists-two .item image {
		width: 100%;
		height: 100%;
		margin-bottom: 10rpx;
		border-radius: 12rpx;
	}

	.lists-two .item .title {
		position: absolute;
		font-size: 28rpx;
		font-weight: 500;
		width: 100%;
		bottom: 0;
		left: 10rpx;
		color: #dedede;
		text-align: center;
	}

	.lists-two .item .title image {
		width: 32rpx !important;
		height: 32rpx;
		margin-right: 15rpx;
	}
</style>